﻿using System;
using UnityEngine;
using UnityEngine.UI;

namespace Assets.Script
{
    public class SortNumIconSprite : MonoBehaviour
    {
        public Text levelText, nameText, numText;
        public int nowlevel, num;
        public string m_name;
        internal void SetLevel(int nowLevel, int v)
        {
            nowlevel = nowLevel * 5;
            levelText.text = ShowCurrencyNum(nowlevel*v);
        }
        private string ShowCurrencyNum(int gold)
        {
            if (gold < 0)
                return "-" + ShowCurrencyNum(-gold);

            if (gold < 1000)
            {
                return gold.ToString();
            }
            else if (gold < 1_000_000)
            {
                return (gold / 1000.0).ToString("0.#") + "k";
            }
            else
            {
                return (gold / 1_000_000.0).ToString("0.#") + "m";
            }
        }
        internal void SetName(string name)
        {
            m_name = name;
            nameText.text = m_name;
        }

        internal void SetNum(int v)
        {
            num = v;
            numText.text = num + "th";
        }
    }
}